<?php

namespace api\modules\v1\models\shop;

use api\modules\common\models\User;
use api\modules\v1\models\Common;
use common\models\Functions;
use yii\base\Exception;
use Yii;
/**
 * This is the model class for table "project_info".
 *
 * @property int $id
 * @property string $name
 */
class GoodsDetail extends \common\models\shop\GoodsDetail
{

    public function getDetail($goodsId = 0) {
        if (empty($goodsId)) {
            return [];
        }

        $where['goods_id'] = $goodsId;
        $detail = static::getByWhere($where);

        foreach ($detail as $k => $v) {
            $detail[$k]['banners'] = GoodsBanner::getBannerByGoodsDetailId($v['id']);
        }

        return $detail;
    }


    public function getOneDetail($goodsId = 0) {
        if (empty($goodsId)) {
            return [];
        }

        $where['goods_id'] = $goodsId;
        $detail = static::getOneByWhere($where, '*', 'list_order ASC');
        $detail['banners'] = GoodsBanner::getBannerByGoodsDetailId($detail['id']);

        return $detail;
    }



}
